package com.wdh.kjs.activity;

import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.wdh.kjs.R;
import com.wdh.kjs.fragment.InvestmentDetailFourFragment;
import com.wdh.kjs.fragment.InvestmentDetailOneFragment;
import com.wdh.kjs.fragment.InvestmentDetailThreeFragment;
import com.wdh.kjs.fragment.InvestmentDetailTwoFragment;

/**
 * Created by DH on 2016/4/21.
 */
public class InvestmentDetailActivity extends Activity implements View.OnClickListener{
    private Button bt_id_introduction;
    private Button bt_id_financing_person;
    private Button bt_id_guarantee;
    private Button bt_id_record;
    private FragmentManager manager;
    private FragmentTransaction transaction;
    private InvestmentDetailOneFragment fragmentOne;
    private InvestmentDetailTwoFragment fragmentTwo;
    private InvestmentDetailThreeFragment fragmentThree;
    private InvestmentDetailFourFragment fragmentFour;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_investment_detail);
        initView();
    }
    private void initView()
    {
        bt_id_introduction=(Button)findViewById(R.id.bt_id_introduction);
        bt_id_financing_person=(Button)findViewById(R.id.bt_id_financing_person);
        bt_id_guarantee=(Button)findViewById(R.id.bt_id_guarantee);
        bt_id_record=(Button)findViewById(R.id.bt_id_record);
        bt_id_introduction.setOnClickListener(this);
        bt_id_financing_person.setOnClickListener(this);
        bt_id_guarantee.setOnClickListener(this);
        bt_id_record.setOnClickListener(this);

        manager=getFragmentManager();
        transaction=manager.beginTransaction();
        fragmentOne=new InvestmentDetailOneFragment();
        transaction.add(R.id.ll_id_list, fragmentOne);
        transaction.commit();
    }

    @Override
    public void onClick(View v) {
        transaction=manager.beginTransaction();
        switch (v.getId())
        {
            case R.id.bt_id_introduction:
            bt_id_introduction.setBackgroundResource(R.drawable.bt_small_blue_style);
            bt_id_financing_person.setBackgroundResource(R.drawable.bt_small_style);
            bt_id_guarantee.setBackgroundResource(R.drawable.bt_small_style);
            bt_id_record.setBackgroundResource(R.drawable.bt_small_style);
            fragmentOne=new InvestmentDetailOneFragment();
            transaction.replace(R.id.ll_id_list, fragmentOne, "fragmentOne");
            transaction.addToBackStack("fragmentOne");
            break;
            case R.id.bt_id_financing_person:
                bt_id_introduction.setBackgroundResource(R.drawable.bt_small_style);
                bt_id_financing_person.setBackgroundResource(R.drawable.bt_small_blue_style);
                bt_id_guarantee.setBackgroundResource(R.drawable.bt_small_style);
                bt_id_record.setBackgroundResource(R.drawable.bt_small_style);
                fragmentTwo=new InvestmentDetailTwoFragment();
                transaction.replace(R.id.ll_id_list, fragmentTwo, "fragmentTwo");
                transaction.addToBackStack("fragmentTwo");
                break;
            case R.id.bt_id_guarantee:
                bt_id_introduction.setBackgroundResource(R.drawable.bt_small_style);
                bt_id_financing_person.setBackgroundResource(R.drawable.bt_small_style);
                bt_id_guarantee.setBackgroundResource(R.drawable.bt_small_blue_style);
                bt_id_record.setBackgroundResource(R.drawable.bt_small_style);
                fragmentThree=new InvestmentDetailThreeFragment();
                transaction.replace(R.id.ll_id_list, fragmentThree, "fragmentThree");
                transaction.addToBackStack("fragmentThree");
                break;
            case R.id.bt_id_record:
                bt_id_introduction.setBackgroundResource(R.drawable.bt_small_style);
                bt_id_financing_person.setBackgroundResource(R.drawable.bt_small_style);
                bt_id_guarantee.setBackgroundResource(R.drawable.bt_small_style);
                bt_id_record.setBackgroundResource(R.drawable.bt_small_blue_style);
                fragmentFour=new InvestmentDetailFourFragment();
                transaction.replace(R.id.ll_id_list, fragmentFour, "fragmentFour");
                transaction.addToBackStack("fragmentFour");
                break;
        }
        transaction.commit();
    }
}
